package testcase;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

import junit.framework.TestCase;
import maincode.currencyStream;

public class CurrencyStreamTest extends TestCase {
	
	
	public void test1(){//public static int getNumber()
		double[] values0 = null;
		double[] rateValues0 = null;
		currencyStream USD = new currencyStream(0, "usd", values0,rateValues0);
		System.out.println(currencyStream.getNumber());
		assertEquals(1, currencyStream.getNumber());
	}
	
	
	 public void test2(){//public static currencyStream getCurSet(int id)
		 				//public static void setCurSet(currencyStream element,int id)
		double[] values3 = null;
		double[] rateValues3 = null;
		currencyStream AUD = new currencyStream(3, "aud", values3,rateValues3);
		currencyStream.setCurSet(AUD,3);
		assertEquals(AUD,currencyStream.getCurSet(3));
	}
	
	public void test3(){//public int getId()
		double[] values4 = null;
		double[] rateValues4 = null;
		currencyStream GBP = new currencyStream(4, "gbp", values4,rateValues4);
		assertEquals(4, GBP.getId());
	}
	public void test4(){//public String getName()
		double[] values5 = null;
		double[] rateValues5 = null;
		currencyStream EUR = new currencyStream(4, "eur", values5,rateValues5);
		assertEquals("eur", EUR.getName());
	}
	public void test5() throws FileNotFoundException{//public double[] getValues()
		File myFile = new File("D:\\data1.txt");
	    Scanner inputFile = new Scanner(myFile);
	    
	    double values1[] = new double[101];
	    double[] rateValues1 = null;
	    int i=0;
	    
	    while (inputFile.hasNext())
	    {
	      
	    	double in = inputFile.nextDouble();
	    	//System.out.println("[" + i++ +"]" + " "+ in);
	    	
	    	values1[i++] = in;
	    
	    }
	    
	    inputFile.close();
	    currencyStream JPY = new currencyStream(1, "jpy", values1,rateValues1);
	    assertEquals(values1, JPY.getValues());
	}
	public void test6()throws FileNotFoundException{//public double getSingleValue(int d)
		File myFile = new File("D:\\data2.txt");
	    Scanner inputFile = new Scanner(myFile);
	    
	    double values2[] = new double[101];
	    double[] rateValues2 = null;
	    int i=0; 
	    
	    while (inputFile.hasNext())
	    {
	      
	    	double in = inputFile.nextDouble();
	    	//System.out.println("[" + i++ +"]" + " "+ in);
	    	
	    	values2[i++] = in;
	    
	    }
	    
	    inputFile.close();
	    currencyStream CNY = new currencyStream(2, "cny", values2, rateValues2);
	    assertEquals(values2[7], CNY.getSingleValue(7));
	}
	
}


